﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class Manage_Service_getQuestionInfo : ManagePageBase
{
    protected int id = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] == null)
        {
            Response.Write("");
            Response.End();
        }
        if (!int.TryParse(Request.QueryString["id"], out id))
        {
            Response.Write(""); Response.End();
        }
        else
        {
            if (!IsPostBack)
            {
                BindQuestion();
            }
        }
    }
    private void BindQuestion()
    {
        Exam.Core.Model.Question model = new Exam.Core.DAL.Question().getModelById(id);

        string Qcontent = "<div>" + Resources.labels.questiontitle+": " + Server.HtmlDecode(model.QuestionContent) + "</div>";
        string QAnswer = "<div>" + Resources.labels.questionAnswer + ": " + Server.HtmlDecode(model.QuestionAnswer.Trim()) + "</div>";
        string divisshowopt = string.Empty;
        if (model.QuestiontypeId.Trim() == "1" || model.QuestiontypeId.Trim() == "2" || model.QuestiontypeId.Trim() == "3")
        {
            divisshowopt = "block";
        }
        else
        {
            divisshowopt = "none";
        }

        List<Exam.Core.Model.QuestionOpts> opts = new Exam.Core.DAL.QuestionOpts().getOptsListByQuestionId(id);
        StringBuilder sb = new StringBuilder();
        sb.Append(Resources.labels.QOpts + ": ");
        foreach (Exam.Core.Model.QuestionOpts o in opts)
        {
            sb.Append("<div>" + Server.HtmlDecode(o.QuestionOptsText) + "</div>");
        }
        string QOptions = sb.ToString();

        Response.Write(Qcontent + QOptions + QAnswer); 
        Response.End();

    }


}